﻿using System;
using System.Text;

namespace GMS.Utils
{
    public static class StringExtend
    {
        /// <summary>
        /// 扩展方法 string转Guid
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public static Guid ToGuid(this string s)
        {
            return Guid.TryParse(s, out _) ? Guid.Parse(s) : Guid.Empty;
        }

        public static byte[] ToBuffer(this string s)
        {
            return Encoding.UTF8.GetBytes(s);
        }

        public static string ToString(this byte[] buffer)
        {
            return Encoding.UTF8.GetString(buffer);
        }

    }
}